function getImg() {
  return Promise.resolve("getImg");
}
function timeout() {
  return Promise.reject("timeout");
}

Promise.race([getImg(), timeout()]).then((res) => {
  console.log(res);
});
